<?php
$eventid = $_['eventid'];
$objecttype = $_['objecttype'];
$data = $_['preview_info'];
$interviewers = isset($_['interviewers']) ? $_['interviewers'] : null;
$sub_date = isset($_['sub_date']) ? $_['sub_date'] : null;
$share_with = isset($_['userid']) ? $_['userid'] : null;
$resume_link = isset($_['resume_link']) ? $_['resume_link'] : null;
$feedback_link = isset($_['feedback_link']) ? $_['feedback_link'] : null;
$allowedit = isset($_['allowedit']) ? $_['allowedit'] : false;
$useremail = isset($_['user']) ? (is_numeric($_['user']->username) ? $_['user']->email : $_['user']->username) : null;
$type =  $_['type'];

?>
<div id="preview_modal">
   <!-- <div class="rightsj"></div>leftsj rightsj -->
   <div class="modal-header">
      <button type="button" class="close">&times;</button>
      <h3 class="songti"><?=$data['title_date']?></h3>
   </div>
   <div class="modal-body medium">
      <?php if ( $objecttype == 'VEVENT' ) : ?>
      <div class="againinterview interviewer_action">
         <div class="notusediv clearfix">
            <b class="pull-left"><?=$data['round']?></b>
            <?php if($type != 'home'): ?>
            <?php if ( $objecttype == 'VEVENT' && $allowedit ) : ?>
               <a id="editEvent" data-eventid="<?=$eventid?>" data-validemail="<?=(!isFakeEmail($data['email']) ? '1':'0')?>" href="javascript:;">修改</a>
               <?php if($data['last_interview_objectid'] == $data['objectid']): ?>
                | 
               <?php if($data['result'] == PCalendarHelper::INTERVIEW_RESULT_CANCEL): ?>
               已取消
               <?php else: ?>
               <a id="cancelEvent" eventtype="<?=$objecttype?>"  data="{jobseekid:<?=$data['jobseekerid'] ?>,jobid:<?=$data['jobid'] ?>,eventid:<?=$eventid ?>,validemail:<?=(!isFakeEmail($data['email']) ? '1':'0')?>}" href="javascript:;">取消面试</a>
               <?php endif; ?>
               <?php endif; ?>
            <?php endif;?>
            <?php endif;?>
         </div>
      </div>
      <?php elseif ( $objecttype == 'VTODO' ): ?>
      <?php if($type != 'home'): ?>
      <div class="againinterview interviewer_action">
         <div class="notusediv clearfix">
            <b class="pull-left">入职</b>
            <a href="javascript:;" id="sendoffer" data="{objectid:'',jobseekid:<?=$data['jobseekerid'] ?>,jobid:<?=$data['jobid'] ?>,eventid:<?=$eventid ?>}">修改</a> | 
            <?php if($data['offer_stat'] == PCalendarHelper::OFFER_FEEDBACKSTATUS_REJECTED): ?>
            已取消
            <?php else: ?>
            <a id="cancelEvent" eventtype="<?=$objecttype?>" data="{jobseekid:<?=$data['jobseekerid'] ?>,jobid:<?=$data['jobid'] ?>,eventid:<?=$data['last_interview_objectid'] ?>}" href="javascript:;">取消入职</a>
            <?php endif; ?>
         </div>
      </div>
      <?php endif;?>
      <?php endif; ?>

      <div class="contentline_each clearfix">
         <span>职&nbsp;&nbsp;&nbsp;位：</span>
         <?php if (!OC_User::isLoggedIn()): ?> 
            <a href="<?php echo OC_Helper::linkToRoute("jobpos_view", array('id'=>$data['jobid'], 'job_title'=>$data['jobtitle']));?>" target="_blank"><?php echo $data['jobtitle']?></a>
         <?php else: ?>
            <a href="<?php echo OC_Helper::linkToRoute("jobpos_setup", array('id'=>$data['jobid'], 'job_title'=>$data['jobtitle']));?>" target="_blank"><?php echo $data['jobtitle']?></a>
         <?php endif; ?>
      </div>
      <div class="contentline_each clearfix">
         <span>姓&nbsp;&nbsp;&nbsp;名：</span>
         <?php if ( !empty($resume_link) ) { // Means it's a share event
            ?>
            <a href="<?=$resume_link?>" target="_blank"><?=$data['jobseekername']?></a>
            <?php
         } else {
            ?>
            <a href="<?php echo OCP\Util::linkToRoute('resume_view', array('id' => $data['jobseekerid'], 'name' => $data['jobseekername']));?>" target="_blank" title="点击查看面试进度和简历"><?=$data['jobseekername']?></a>
            <?php
         }?>
      </div>
      <?php if ( $objecttype == 'VEVENT' && empty($sub_date) ) { ?>
         <div class="contentline_each clearfix"><span>面&nbsp;&nbsp;&nbsp;试：</span>
            <div class="timelist pull-left">
               <?php if ( !empty($interviewers) ) { //  Master event
                  foreach ($interviewers as $k => $v) {
                     ?>
                     <div class="eachinterviewer">
                        <span><?php echo $v['start_time'];?> - <?php echo $v['end_time'];?></span>
                        <?php echo strmaxtextlen($v['show_name'],7);?>
                        <?php if($type != 'home'): ?>
                        <span class="feedbacklink">
                           <?php
                           if ( isset($feedback_link) ) {
                              // It's share condition
                              if ( $share_with == $v['email'] && $v['suggestion_id'] === null ) {
                                 ?>
                                 <a href="<?=$feedback_link?>" target="_blank">写反馈</a>
                                 <?php
                              } elseif ( $v['suggestion_id'] === '0' ) {
                                 ?>
                                 <a href="<?php echo OC_Helper::linkToRoute("calendar_interviewfeedback", array('id' => $v['objectid']));?>" target="_blank">应聘者缺席</a>
                                 <?php
                              } elseif ( !empty($v['suggestion']) ) {
                                 ?>
                                 <a href="<?php echo OC_Helper::linkToRoute("calendar_interviewfeedback", array('id' => $v['objectid']));?>" target="_blank"><?=$v['suggestion']?></a>
                                 <?php
                              }
                           } else {
                              // Generate feedback link
                              if ( $useremail == $v['email'] && $v['suggestion_id'] === null ) {
                                 ?>
                                 <a href="<?php echo PCalendarHelper::getPublicShareLink('event',$v['token'],$v['email']).'&feedback=1';?>" target="_blank">写反馈</a>
                                 <?php
                              } elseif ( $v['suggestion_id'] === '0' ) {
                                 ?>
                                 <a href="<?php echo OC_Helper::linkToRoute("calendar_interviewfeedback", array('id' => $v['objectid']));?>" target="_blank">应聘者缺席</a>
                                 <?php
                              } elseif ( !empty($v['suggestion']) ) {
                                 ?>
                                 <a href="<?php echo OC_Helper::linkToRoute("calendar_interviewfeedback", array('id' => $v['objectid']));?>" target="_blank"><?=$v['suggestion']?></a>
                                 <?php
                              } elseif ( $allowedit ) {
                                 // Remind
                                 ?>
                                 <a id="remind" data="{objectid:<?=$v['objectid']?>,jobid:<?=$data['jobid']?>}" style="color:#d2871d" href="javascript:;">提醒反馈</a>
                                 <?php
                              }
                           }
                           ?>
                        </span>
                        <?php endif; ?>
                     </div>
                     <?php
                  }
               }?>
            </div>
         </div>
      <?php
      } elseif ( $objecttype == 'VEVENT' && !empty($sub_date) ) { // Shared sub-event
         ?>
         <div class="contentline_each clearfix"><span>面&nbsp;&nbsp;&nbsp;试：</span><?php echo $sub_date['start_time'];?> - <?php echo $sub_date['end_time'];?></div>
         <?php
      } elseif ( $objecttype == 'VTODO' ) {
         ?>
         <div class="contentline_each clearfix"><span>入&nbsp;&nbsp;&nbsp;职：</span><?php echo $data['entry_deadline']?></div>
         <?php
      }?>
      
      <?php if(0): ?>
      <div class="contentline_each clearfix"><span>备&nbsp;&nbsp;&nbsp;注：</span>
         <div class="timelist pull-left">
            <div class="beizhucolor">此人经验丰富，面试时请着重了解下熟悉技能等等。另外，请注意逻辑是否清晰。</div>
         </div>
      </div>
      <?php endif; ?>
      
   </div>
</div>
